package com.ruoyi.inspection.utils;

public class IdFactory {
    private static final SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
    @Deprecated
    public static Long getNewId(){
        LongId id = new LongId();
        return id.toLong();
    }

    public static Long newLongId(){
        return getSnowflakeId();
    }

    public static Long getSnowflakeId(){
        return idWorker.nextId();
    }

    /**
     * 简短code
     * shortUrlCode
     * @return
     */
    public static String genShortCode(){

        return ShortUrlUtils.ShortTextOne();
    }

    /**
     * 使用,32位UUID
     * @return
     */
    public static String genCode(){
        return IdUtils.fastSimpleUUID();
    }

    //==============================Test=============================================
    /** 测试 */
    public static void main(String[] args) throws InterruptedException {


      /*  for (int i = 0; i < 100; i++) {
            new Thread(()->{
                long id = getSnowflakeId();
                //System.out.println(Long.toBinaryString(id));
                System.out.println(id);
            }).start();

            long id = IdFactory.getSnowflakeId();
            //System.out.println(Long.toBinaryString(id));
            System.out.println(id);
        }
        //Thread.sleep(100000);

        System.out.println(IdUtils.fastSimpleUUID());
        System.out.println(IdUtils.fastUUID());
        System.out.println(IdUtils.randomUUID());
        System.out.println(IdUtils.simpleUUID());*/

        System.out.println(IdFactory.genCode());
        //IdFactory.genShortCode();
        System.out.println(IdFactory.getNewId());
        /* C.println(IdFactory.genShortCode("22fff"));*/
    }
}
